{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box no-header clearfix">
	
	<div class="main-box-body clearfix">
		<!-- 表格列表 -->

		<div class="tabs-wrapper">
				<ul class="nav nav-tabs">
					<li class="active"><a href="#tab我的结算单" data-toggle="tab">我的结算单</a></li>
				</ul>
				<div class="tab-content">
				    <div class="tab-pane fade in active" id="tab订单统计">
					<div class="row">
						<div class="col-md-6">
							<div class="well">
								<b>结算单总额</b>
								<div class="text-primary" style="font-size:32px;margin:5px 0">
									&yen;{$balmoney|number_format=###,2}              <span class="text-muted" style="font-size:13px">
										总充值: <b class="text-warning">&yen;{$pay|number_format=###,2}</b>
									</span>
								</div>
								<div style="font-size:14px" class="text-muted">
									未提现: <b class="text-warning">&yen;{$wmoney|number_format=###,2}</b>,
									提现中: <b class="text-warning">&yen;{$zmoney|number_format=###,2}</b>
									已打款: <b class="text-warning">&yen;{$ymoney|number_format=###,2}</b>
								</div>
							</div>
						</div>
						<div class="col-md-6">
							<div class="well">
								<b>未申请提现余额
									<span style="font-weight:normal;font-size:13px;color:#090" class="pull-right">
									当天的次日结算
									</span>
								</b>
								<div class="text-primary" style="font-size:32px;margin:5px 0">
									&yen;{$wmoney|number_format=###,2}                <button type="button" data-toggle="modal" data-target="#myModal" class="btn btn-sm btn-primary">申请提现</button>
									<a href="{:url('cashlog')}" class="btn btn-sm btn-primary">提现记录</a>
								</div>
								<div style="font-size:14px;" class="text-muted">
									申请提现总额: <b class="text-warning">&yen;{$allcsah|number_format=###,2}</b>,
									已打款: <b class="text-warning">&yen;{$ycsah|number_format=###,2}</b>,
									待打款: <b class="text-warning">&yen;{$wcsah|number_format=###,2}</b>
								</div>
							</div>
						</div>
					</div>
					<ul class="nav nav-tabs">
						<li {if $status ==0}class="active"{/if}>
							<a href="{:url('index',array('status'=>0))}">未提现</a>
						</li>
						<li {if $status ==2}class="active"{/if}>
							<a href="{:url('index',array('status'=>2))}">提现中</a>
						</li>
						<li {if $status ==1}class="active"{/if}>
							<a href="{:url('index',array('status'=>1))}">已打款</a>
						</li>
					</ul>

					<table class="table table-striped table-bordered table-hover responsive">
						<thead>
						<tr>
							<td>
								日期
							</td>
							<td>
								结算类型
							</td>
							<td>
								渠道/代理
							</td>
							<td>
								总笔数
							</td>
							<td class="text-center">
								充值金额
							</td>
							<td class="text-center">
								帐单金额
							</td>
							<td class="text-center">
								佣金比例
							</td>
							<td>
								状态
							</td>
						</tr>
						</thead>
						<tbody>
						{if condition="empty($list)"}
							<tr>
								<td colspan="6" align="center">暂无数据！</td>
							</tr>
						{else/}
							{volist name="list" id="item"}
								<tr>
									<td>
										<a href="{:url('cashdetail',array('id'=>$item.id))}">{$item.create_time|date='Y-m-d',###}</a>
									</td>
									<td>
										{$item['type']==1?"推广收益":"盈利差收益"}
									</td>
									<td>
										{$item.uid|get_username}
									</td>
									<td>{$item.num}</td>
									<td class="text-right">{$item.money|number_format=###,2}</td>
									<td class="text-right"><strong>{$item.balmoney|number_format=###,2}</strong></td>
									<td class="text-right">{$item.percentage}</td>
									<td>
										<a class="btn btn-xs btn-pending" href="{:url('cashdetail',array('id'=>$item.id))}">
										{switch $item.status}
											{case value="0"}未提现{/case}
											{case value="1"}已打款{/case}
											{case value="2"}提现中{/case}
										{/switch}             </a>
									</td>
								</tr>
							{/volist}
						{/if}
								</tbody>
					</table>
					{$page}
					</div>
				</div>
		</div>
		<!-- /表格列表 -->
	</div>
</div>

{if $wmoney > $Think.config.cashlimit}
<!-- 模态框（Modal） -->
<form method="post" action="" class="form-horizontal" id="form_data" onsubmit="return submit_form()">
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<input type="hidden" name="uid" value="{$Think.session.user_auth.uid}">
	<input type="hidden" name="money" value="{$wmoney}">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					申请提现
				</h4>
			</div>
			<div class="modal-body">
				你本次提现的金额为：<font size="14" color="#ff3300">&yen;{$wmoney|number_format=###,2}</font>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
				<button type="submit" class="btn btn-primary">
					提交
				</button><span id="tip"> </span>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
{else}
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<input type="hidden" name="uid" value="{$Think.session.user_auth.uid}">
	<input type="hidden" name="money" value="{$wmoney}">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					申请提现
				</h4>
			</div>
			<div class="modal-body">
				余额满{$Think.config.cashlimit|number_format=###,2}元才能提现
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
{/if}
<script> 

    // 提交表单
    function submit_form()
    {
        //var user_id = $.trim($('#user_id').val());		
        var form_data = $('#form_data').serialize();
		var url = "{:url('applycash')}";
        // 异步提交数据
        $.ajax(
			{
				url: url,
				data:{"form_data":form_data},
				type: "post",
				beforeSend:function()
				{
					$("#tip").html("<span style='color:blue'>正在处理...</span>");
					return true;
				},
				success:function(data)
				{
					if(data > 0)
					{						
						$("#tip").html("<span style='color:blueviolet'>恭喜，申请成功！</span>");
						location.reload();
					}
					else
					{
						$("#tip").html("<span style='color:red'>失败，请重试</span>");
					}
				},
				error:function()
				{
					alert('请求出错');
				},
				complete:function()
				{
					$('#acting_tips').hide();
				}
			});
        return false;
    }
</script>
{/block}